/**
 * @author tibi
 */
function EntityFieldsGrid(){
	var PresidentsColumnModel;
	var PresidentsDataStore
	var storeDefinition;
	Ext.Ajax.request({
		url: 'server/EntityDefinition.php?__id='+node.id,
		success: function(response) {
			r = response.responseText;
			var gridDefinition = eval(r);
			StoreDefinition = eval(gridDefinition.Store);
			ColumnsModel = eval(gridDefinition.ColumnModel);
			//alert(EntitiesDefinition);
			PresidentsDataStore = new Ext.data.Store({
		      id: 'PresidentsDataStore',
		      proxy: new Ext.data.HttpProxy({
		                url: '//localhost/googled/server/database.php',      // File to connect to
		                method: 'POST'
		            }),
		            baseParams:{task: "LISTING"}, // this parameter asks for listing
		      reader: new Ext.data.JsonReader({   // we tell the datastore where to get his data from
		        root: 'results',
		        totalProperty: 'total',
		        id: 'id'
		      },StoreDefinition),
		      sortInfo:{field: 'IDpresident', direction: "ASC"}
		    });
			PresidentsColumnModel = new Ext.grid.ColumnModel(ColumnsModel);
		    PresidentsColumnModel.defaultSortable= true;
		}
		});
	EntityListingEditorGrid =  new Ext.grid.EditorGridPanel({
	      id: node.id + "_EditorGrid",
		  title: node.text,
	      store: PresidentsDataStore,     // the datastore is defined here
	      cm: PresidentsColumnModel,      // the columnmodel is defined here
	      enableColLock:false,
	      clicksToEdit:1,
		  tbar: [
			  '-', 
			  new Ext.app.SearchField({
			  store: PresidentsDataStore,
			  params: {start: 0, limit: 15},
			  width: 120
			})
		  ],
		  bbar: new Ext.PagingToolbar({
                pageSize: 15,
                store: PresidentsDataStore,
                displayInfo: true
            }),
	      selModel: new Ext.grid.RowSelectionModel({singleSelect:false})
	    });
	PresidentsDataStore.load({params: {start: 0, limit: 15}});
	EntityListingEditorGrid.closable = true;
	return EntityListingEditorGrid;
}
